{% extends "base.html" %}
{% load static %}
{% load gravatar %}
{% load databasefilters %}



{% block title %}RMG: Solvation Search{% endblock %}

{% block extrahead %}
<script type="text/javascript">
// Show a loading animation when after hitting the submit button.
$().ready(function(){
   $('[name$=submit]').click(function() {
      if ($('[name$=solvent_solute_smiles]').val()){
         $('#searching').show(); }
      });
});
</script>
{% endblock %}

{% block navbar_items %}
<li><a href="{% url 'database:solvation-search' %}">Solvation Tools</a></li>
<li><a href="{% url 'database:solvation-searchML' %}">Solvation Prediction 298 K Using Machine Learning</a></li>
{% endblock %}

{% block page_title %}Solvation Prediction at 298 K Using Machine Learning{% endblock %}

{% block page_body %}

<p>
Use this form to get solvation free energy, solvation enthalpy, and solvation entropy prediction at 298 K for a
    solvent-solute pair of your interest. Currently, we only support prediction for electrically neutral solute
    compounds containing H, C, N, O, S, P, F, Cl, Br, and I and pure nonionic liquid solvents. Mixture solvents are
    currently not supported. The prediction is made using the <b>DirectML</b> machine learning model, which is trained
    on 20253 experimental solvation free energy and 6322 experimental solvation enthalpy data.
    Note that the DirectML model is not trained for radical compounds.
    Solvation free energy is calculated using the standard state of an ideal gas at a concentration of 1 mol/L
    dissolving as an ideal solution at a concentration of 1 mol/L.
</p>
<p>
Details on the DirectML model can be found in the publication shown below. Please cite our
    work if you wish to use any results.<br>
   <ul> <li>Chung, Y, Vermeire, FH, Wu, H, Walker, PJ, Abraham, MH, Green, WH. Group contribution and machine learning
   approaches to predict Abraham solute parameters, solvation free energy, and solvation enthalpy.
   <i>Manuscript in Preparation</i>. 2021.</li></ul>
</p>

<p>
    Partition coefficients, log<script type="math/tex">K</script> and dry log<script type="math/tex">P</script>,
    are also calculable. The liquid/gas partition coefficient <script type="math/tex">K</script> is defined as
    the concentration ratio of a solute compound between a liquid and a gas phase at equilibrium and is directly
    related to the solvation free energy. The organic/water partition coefficient
    <script type="math/tex">P</script> is defined as the concentration ratio of a solute compound between an
    organic solvent and an aqueous phase at equilibrium.
</p>
<div class="math notranslate nohighlight" id="equation-abmodeleqn">
    \[K = \frac{c_{\rm solute, liquid}}{c_{\rm solute, gas}} =
    \exp \left(\frac{-\Delta G_{\rm solv}^{*}}{RT}\right)\]</div>
<div class="math notranslate nohighlight" id="equation-abmodeleqn">
    \[P = \frac{c_{\rm solute, organic}}{c_{\rm solute, water}} =
    \exp \left(\frac{-\left( \Delta G_{\rm solv, organic}^{*} - \Delta G_{\rm solv, water}^{*} \right)}{RT}\right)\]</div>
<p>
    This tool calculates log<script type="math/tex">P</script> values by using the input solvent as an organic phase
    and assumes a dry solvent (<i>i.e.</i> organic solvent is not in contact with water).
    Both log<script type="math/tex">K</script> and dry log<script type="math/tex">P</script> are calculated using
    the logarithm with base 10.
</p>

<p>
   Note that this tool is not designed for bulk queries. For bulk queries or automatic calculations, one can install
   the DirectML model as a conda package 'chemprop_solvation' from
   <a href="https://anaconda.org/fhvermei/chemprop_solvation"> here</a>.
</p>

<P>Enter SMILES of a solvent and solute compound, separated by the underscore ( _ ), in the field below to search.
    (e.g. for a solvent water (O) and a solute ethanol (CCO), the input should be O_CCO)
    Do not put any empty space between the solvent and solute SMILES. For multiple solvent-solute pairs, separate each
    pair by line or empty space. A maximum of 50 solvent-solute pairs are allowed for each calculation.
    It should take less than 1 minute to calculate solvation free energies of 50 solvent-solute pairs and could take
    more time if more options are selected.

<div style="display:none" id="searching">
<img src="{% static 'img/loading.gif' %}" alt="Loading..." id='loading_image'>
   <p>Due to our server capacity,</p>
   <p><strong>- Please wait patiently after submitting your search request. It may take a few minutes.</strong></p>
   <p><strong>- Please do not submit multiple solvation searches simultaneously.</strong></p>
   <p>If you keep receiving 'Gateway Timeout' error, it indicates your search takes longer time than the limit. Please contact <a href="mailto:rmg_dev@mit.edu">the RMG Development Team</a> for help.</p>
</div>

<form method="post" id="species_form">
<table>
   <tr>
      <th><b>Input Solvent & Solute SMILES(s):	</b></th>
      <td>{{form.solvent_solute_smiles}}</td>
   </tr>
   {% if form.errors.solvent_solute_smiles %}
      <tr>
         <td colspan="2", align="center"><b style="color:red;">{{ form.errors.solvent_solute_smiles }}</b></td>
      </tr>
   {% endif %}
   </tr>
   <tr>
       <th>&nbsp;</th>
   </tr>
   <tr>
       <th><b>Select all that you want:</b></th>
       <td>
           solvation free energy {{form.calc_dGsolv}} &nbsp; &nbsp; solvation enthalpy {{form.calc_dHsolv}} &nbsp; &nbsp;
           solvation entropy {{form.calc_dSsolv}}
       </td>
   </tr>
   <tr>
       <th>&nbsp;</th>
       <td>
           logK {{form.calc_logK}} &nbsp; &nbsp; logP{{form.calc_logP}}
       </td>
   </tr>
   {% if form.errors.option_selected %}
      <tr>
         <td colspan="2", align="center"><b style="color:red;">{{ form.errors.option_selected }}</b></td>
      </tr>
   {% endif %}
   <tr>
       <th>&nbsp;</th>
   </tr>
   <tr>
       <th><b>Preferred unit:</b></th>
       <td>{{form.energy_unit}}</td>
   </tr>
   <tr>
       <th>&nbsp;</th>
   </tr>
   <tr>
      <th>{% csrf_token %}</th>
      <td>
         <input type="submit" value="Submit" name="submit" />
         <input type="submit" value="Reset Form" name="reset" />
      </td>
   </tr>
</table>
</form>

{% endblock %}s